package com.foreknow.eldclient.service.impl;

import com.foreknow.eldclient.dao.OrderDetailetMapper;
import com.foreknow.eldclient.dao.OrdersMapper;
import com.foreknow.eldclient.po.OrderDetailet;
import com.foreknow.eldclient.service.OrderDetailetService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class OrderDetailetServiceImpl implements OrderDetailetService {
    @Autowired
    OrderDetailetMapper ODM;
    @Autowired
    OrdersMapper OM;
    @Override
    public int saveOrderDetailetBatch(OrderDetailet orderDetailet) throws Exception {
        return ODM.saveOrderDetailetBatch(orderDetailet);
    }

    @Override
    public List<OrderDetailet> listOrderDetailetByOrderId(Integer orderId) throws Exception {
        List<OrderDetailet> list = ODM.listOrderDetailetByOrderId(orderId);
        for (OrderDetailet orderDetailet : list) {
            orderDetailet.setOrder(OM.getOrdersById(orderDetailet.getOrderId()));
        }
        return list;
    }

    @Override
    public List<OrderDetailet> getfoodIdByOrderId(int orderId) throws Exception {
        return ODM.getODByOrderId(orderId);
    }
}
